package com.exam.api.dao;

import com.exam.api.common.BaseDao;
import com.exam.api.dto.ExamDetailDTO;
import com.exam.api.vo.InfoVO;
import com.exam.api.vo.QuestionVO;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @description: 分数详情持久层
* @author: wuming
* @create: 2024.05.03 13:24:03
*/
public interface ExamDetailDao extends BaseDao<ExamDetailDTO> {

    @Select("select s.name,student_id,sum(grade) grade FROM  exam_detail e left join student s on s.id = e.student_id WHERE  exam_id = #{examId} group by student_id order by grade asc ")
    List<InfoVO> getInfo(Long examId);

    @Select("select  question_id,s.question_name ,avg(e.grade) avg FROM  exam_detail e left join questions s on s.id = e.question_id WHERE  e.exam_id = #{examId} group by question_id")
    List<QuestionVO> getQuestion(Long examId);
}
